package com.guodexian.vo;

import lombok.Data;

/**
 * 类说明：<br>
 *
 * @author qfrx<br>
 * 2024/12/26 11:21<br>
 * @since 1.0 <br>
 */
@Data
public class R<T> {
    /**
     * code:例如0表示成功，非0失败
     */
    private int code;
    private String msg;
    private T data;
    //防止乱创建对象，因为成功对象不需要多个
    private R(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    //static可以直接通过类名访问
    public static final R OK=new R<>(0,"success");
    public static final R FAIL=new R<>(1,"fail");
    //串联语法，直接返回
    public R setData(T data) {
        this.data = data;
        return this;
    }
    //串联语法，直接返回
    public R setMsg(String msg) {
        this.msg = msg;
        return this;
    }
    //串联语法，直接返回
    public R setCode(int code) {
        this.code = code;
        return this;
    }
}
